import { fileURLToPath, URL } from 'node:url'

import { defineConfig,loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'

// https://vitejs.dev/config/
export default defineConfig(({mode})=>{
  const env = loadEnv(mode,process.cwd())
  return {
    plugins: [
      vue(),
      vueJsx(),
    ],
    server: {
      port: 7777,
      open:true,
      host:"localhost",
      proxy:{
              [env.VITE_APP_TITLE]: {
                  target: 'http://localhost:8888',
                  changeOrigin: true,
                  rewrite: (path) => path.replace(/`^\/${env.VITE_APP_TITLE}`/, '')
                      }
      }
    },
    
    resolve: {
      alias: {
        '@': fileURLToPath(new URL('./src', import.meta.url))
      }
    }
  }
})
